home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / tools / exe2com.com / EXE2COM.DOC < prev    next >
Encoding:
Text File  |  1990-09-10  |  13.4 KB  |  341 lines

  1.                                   EXE2COM 1.05
  2.                          By Chris Dunford/Cove Software
  3.  
  4.         | indicates information changed/added in recent versions.
  5.  
  6.         Purpose
  7.         -------
  8.         EXE2COM is a one-for-one replacement for the EXE2BIN program
  9.         that was formerly distributed with DOS.  Beginning with DOS 3.3,
  10.         EXE2BIN has been moved to the disk that comes with the DOS
  11.         Technical Reference and thus is not available without extra
  12.         cost.
  13.  
  14.  
  15.         Usage
  16.         -----
  17.         Usage is identical to DOS's EXE2BIN except that the output file
  18.         extension defaults to COM rather than BIN, and there are two
  19.         optional switches.
  20.  
  21.         Complete usage is:
  22.  
  23.       |     EXE2COM [/IR] [d:][path]file[ext] [d:][path][file][ext]
  24.  
  25.         The drive and path of the first file default to the current
  26.         drive and path, if not specified.  The extension of the first
  27.         file defaults to EXE, if not specified.
  28.  
  29.         If the second file is completely unspecified, it defaults to the
  30.         same drive, path, and filename as the first, except that the
  31.         extension will be COM.
  32.  
  33.         If the second file is specified but without an extension, COM
  34.         will be assumed (this is different from EXE2BIN).
  35.  
  36.         If /I is specified, information about the EXE file is displayed
  37.         and no conversion is performed.  The output file name, if
  38.         specified, is ignored.
  39.  
  40.       | If /R is specified and the EXE file contains relocatable items,
  41.       | the relocation table is displayed (see below).
  42.  
  43.         The simplest (and usual) usage is simply:
  44.  
  45.             EXE2COM file
  46.  
  47.         which will take the named EXE file in the current directory and
  48.         convert it to a COM file in the same directory.
  49.  
  50.  
  51.         Operation
  52.         ---------
  53.         EXE2COM runs the same way as EXE2BIN, with the following
  54.         exceptions:
  55.  
  56.             1. The binary fixup option of EXE2BIN (IP=0, segment fixups
  57.             required) is not supported.
  58.  
  59.             2. The EXE file checksum is not verified.
  60.  
  61.             3. Error messages are more useful, and a warning is provided
  62.             if a COM file is created with an initial IP other than 100H.
  63.  
  64.             4. The default output file extension is COM rather than BIN.
  65.  
  66.  
  67.         Information display
  68.         -------------------
  69.         If you use the /I switch, EXE2COM just displays information
  70.         about the EXE file and does not attempt to convert it to COM
  71.         (therefore, the EXE file need not be a convertible file).  Here
  72.         is a typical display, resulting from running EXE2COM on itself
  73.         (version 1.04) with the /I switch:
  74.  
  75.           exe2com.exe                   (hex)      (dec)
  76.             EXE file size                396B      14699
  77.             EXE header size (para)         20         32
  78.             Program image size (bytes)   376B      14187
  79.             Minimum load size (bytes)    8CDB      36059
  80.             Min allocation (para)         557       1367
  81.             Max allocation (para)        FFFF      65535
  82.           * Initial CS:IP           0000:072C
  83.           * Initial SS:SP           084D:0800       2048 (stack size)
  84.           * Relocation count                4          4
  85.             Relo table start             001E         30
  86.             EXE file checksum            411D      16669
  87.             Overlay number                  0          0
  88.           * = this item prevents conversion to BIN/COM
  89.  
  90.         The fields that may need some explanation:
  91.  
  92.         Program image size:  this is the size of the program itself
  93.         (i.e., the size of the EXE file less the size of the header
  94.         information).  This much memory is required to load a copy of
  95.         the program's code and pre-allocated data.
  96.  
  97.         Minimum load size: at least this much free memory is required in
  98.         order to run the program.
  99.  
  100.         Min/max allocation: the minimum/maximum number of 16-byte
  101.         paragraphs that will be needed above the end of the program
  102.         image when it is loaded.  Minimum load size is the sum of the
  103.         program image size and the minimum allocation.
  104.  
  105.         Relocation count: see below.
  106.  
  107.         If an item is starred (*), this prevents the EXE file from being
  108.         converted to a COM file.
  109.  
  110.  
  111.       | Relocatable items
  112.       | -----------------
  113.       | The most common reason why a file cannot be converted to COM
  114.       | or SYS format is that it has "relocatable items."
  115.       |
  116.       | A relocatable item is a piece of code that must be "fixed up"
  117.       | when the program is run because it changes with the program's
  118.       | load address.  Consider this code fragment:
  119.       |
  120.       |     code segment byte public
  121.       |     mov ax,code
  122.       |     ...
  123.       |
  124.       | What gets moved into AX is CODE's segment address, which is
  125.       | not known until runtime.  The assembler can't specify the
  126.       | value to be loaded into AX because it doesn't know where in
  127.       | memory the program will be loaded.  Only the EXE file loader
  128.       | can perform this operation; hence, it can't be converted into
  129.       | a COM or SYS file.
  130.       |
  131.       | The EXE file header contains one entry for each such relocatable
  132.       | item.  This entry consists of the segment and offset of the word
  133.       | that must be fixed up at runtime.  Note that the "segment" is
  134.       | relative to the first segment of the program; the first segment
  135.       | will be 0000.
  136.       |
  137.       | If you see the message "EXE contains relocatable items", you can
  138.       | ask EXE2COM to find the items by re-running it with the /R
  139.       | /R switch:
  140.       |
  141.       |     exe2com /r myprog
  142.       |
  143.       | EXE2COM might display something like this:
  144.       |
  145.       |     relocation table:
  146.       |       0000:00AF  0000:01C3
  147.       |
  148.       | This shows that there are two relocatable items in the EXE file
  149.       | and that they are located at the specified segment:offset
  150.       | addresses.  The first relocatable item in this case is located
  151.       | at offset 00AFh of the program's first segment.
  152.       |
  153.       | A list (.LST) file can be very helpful in finding your
  154.       | relocatable items: for each one (in the opcode column), you will
  155.       | see a "----" where a number should be.  In the example, it
  156.       | might look like:
  157.       |
  158.       |     00AE  B8 ---- R              mov ax,code
  159.       |
  160.       | EXE2COM's relocation table display can be helpful in letting
  161.       | you know where to look for the error.
  162.       |
  163.       | To correct the problem, restate the instruction in a way that
  164.       | doesn't require a direct reference to a segment.  For example,
  165.       | you might recode "mov ax,code" as "mov ax,cs" (assuming that CS
  166.       | points to the CODE segment).
  167.  
  168.  
  169.         Error Messages
  170.         --------------
  171.         These are EXE2COM's error messages.  If one of these is seen,
  172.         the EXE file will not be converted and the errorlevel returned
  173.         by EXE2COM will be 1.
  174.  
  175.         ERROR READING EXE HEADER
  176.             EXE2COM was unable to read the EXE file header from disk.
  177.  
  178.         ERROR WRITING OUTPUT FILE
  179.             EXE2COM was unable to write the converted file to disk.
  180.  
  181.         INVALID EXE FILE SIGNATURE
  182.             The first two bytes of an EXE file should be ASCII 'M' and
  183.             'Z'.  This was not the case, and it's probably not an EXE
  184.             file.
  185.  
  186.         EXE HAS RELOCATABLE ITEMS
  187.             In order to be converted to a COM file, an EXE file cannot
  188.             have any direct references to segments.  For example, the
  189.             assembler instruction "mov ax,code" (where CODE is a segment
  190.             name) is a segment reference.  One or more segment
  191.             references were found in the EXE file.  See above.
  192.  
  193.         EXE HAS STACK SEGMENT
  194.             In order to be converted to a COM file, an EXE file cannot
  195.             have a stack segment.
  196.  
  197.         EXE HAS NONZERO CS
  198.             In order to be converted to a COM file, an EXE file must
  199.             have a code segment that begins at offset 0 of the code
  200.             image in the EXE file.
  201.  
  202.         IP NOT 0 OR 100H
  203.             In order to be converted to a binary file, an EXE file must
  204.             have an entry point of 0 or 100H within the code segment.
  205.             For COM files, the entry point should be 100H.  For SYS
  206.             files (device drivers), the entry point should be 0.
  207.  
  208.         PROGRAM EXCEEDS 64K
  209.             In order to be converted to a binary file, the total size of
  210.             the code to be loaded (including the PSP) must not exceed
  211.             64K bytes.
  212.  
  213.         UNKNOWN ERROR
  214.             Internal error.  Notify the author.
  215.  
  216.  
  217.         Warning message
  218.         ---------------
  219.         EXE2COM has one warning message:
  220.  
  221.             COM FILE, INITIAL IP NOT 100H
  222.  
  223.         The entry point of all COM files should be 100H.  If you are
  224.         creating a COM file an the entry point is not 100H, EXE2COM will
  225.         do the job but let you know that there is a potential problem.
  226.  
  227.  
  228.         Source
  229.         ------
  230.         Source code should be included with this archive.  Users are
  231.         encouraged to modify, improve, and/or correct the source for
  232.         EXE2COM and submit the new program to the author for
  233.         distribution.  Please identify clearly any changes made and
  234.         stick with portable code to the extent possible (no inline
  235.         assembler, PLEASE).
  236.  
  237.         EXE2COM.EXE was compiled with Microsoft C 6.0, but I believe
  238.         that it will compile correctly with Borland's Turbo C (I don't
  239.         have TC, so can't swear to this).  It should be easily portable
  240.         to most other compilers.
  241.  
  242.  
  243.         Public domain
  244.         -------------
  245.         EXE2COM is hereby donated by the author to the public domain.
  246.  
  247.  
  248.         History
  249.         -------
  250.         Version 1.00 04/17/87: Original version by
  251.             Christopher J. Dunford
  252.             The Cove Software Group
  253.             PO Box 1072
  254.             Columbia, MD 21044
  255.             (301) 992-9371
  256.             CompuServe 76703,2002
  257.  
  258.         Version 1.01: port to Turbo C by
  259.             Roger Schlafly
  260.             Borland International
  261.             Scotts Valley, CA 95066
  262.             CompuServe 76067,511
  263.  
  264.         Version 1.02 11/22/87: bug fix for even 512-byte file made to
  265.         Turbo C port by
  266.             Chris Blum ( Consultant )
  267.             509 West Main, Front
  268.             Ashland, Ohio 44805
  269.             CompuServe 76625,1041
  270.  
  271.             Chris Dunford duplicated the fix in the C86 source.
  272.  
  273.         Version 1.03 12/30/87: by Chris Dunford
  274.             Ported to Microsoft C 5.0.  This is now the "official"
  275.             version.
  276.  
  277.             Increased size of I/O buffer to 4K for speed reasons.
  278.             EXE2COM 1.03 is twice as fast as 1.02 and slightly
  279.             faster than EXE2BIN.
  280.  
  281.         Version 1.04 03/08/88: by Chris Dunford
  282.             Cleaned up some old code from the original quickie.
  283.  
  284.             Source should now compile under either MSC or TC.
  285.  
  286.             Added /I switch.
  287.  
  288.             In earlier versions, we defined an error code for nonzero
  289.             CS, but didn't actually check; now we do.
  290.  
  291.         Version 1.05 08/23/90: by Chris Dunford
  292.             Added /R (relo table) switch
  293.  
  294.  
  295.          ----------------end-of-author's-documentation---------------
  296.  
  297.                          Software Library Information:
  298.  
  299.                     This disk copy provided as a service of
  300.  
  301.                            Public (software) Library
  302.  
  303.          We are not the authors of this program, nor are we associated
  304.          with the author in any way other than as a distributor of the
  305.          program in accordance with the author's terms of distribution.
  306.  
  307.          Please direct shareware payments and specific questions about
  308.          this program to the author of the program, whose name appears
  309.          elsewhere in  this documentation. If you have trouble getting
  310.          in touch with the author,  we will do whatever we can to help
  311.          you with your questions. All programs have been tested and do
  312.          run.  To report problems,  please use the form that is in the
  313.          file PROBLEM.DOC on many of our disks or in other written for-
  314.          mat with screen printouts, if possible.  PsL cannot debug pro-
  315.          programs over the telephone, though we can answer questions.
  316.  
  317.          Disks in the PsL are updated  monthly,  so if you did not get
  318.          this disk directly from the PsL, you should be aware that the
  319.          files in this set may no longer be the current versions. Also,
  320.          if you got this disk from another vendor and are having prob-
  321.          lems,  be aware that  some files may have become corrupted or
  322.          lost by that vendor. Get a current, working disk from PsL.
  323.  
  324.          For a copy of the latest monthly software library newsletter
  325.          and a list of the 2,000+ disks in the library, call or write
  326.  
  327.                            Public (software) Library
  328.                                P.O.Box 35705 - F
  329.                             Houston, TX 77235-5705
  330.  
  331.                                 1-800-2424-PSL
  332.                                  MC/Visa/AmEx
  333.  
  334.                           Outside of U.S. or in Texas
  335.                           or for general information,
  336.                               Call 1-713-524-6394
  337.  
  338.                           PsL also has an outstanding
  339.                           catalog for the Macintosh.
  340.  
  341.